#include "utils.h"

namespace utils {

vector<string> split_string(const string& str, const string& ch) {
  vector<string> result;

  string::size_type cur = string::npos;
  string::size_type back = 0;
  while(true) {
    string::size_type cur = str.find(ch, back);
    if (cur == string::npos) {
      if (str.length() != back) {
        result.push_back(str.substr(back, str.length() - back));
      }
      break;
    }
    result.push_back(str.substr(back, cur - back));
    back = cur + ch.length();
  }

  return result;
}

}  // namespace utils

